<!DOCTYPE html>
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<title>{$_W['uniaccount']['name']}</title>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<meta name="viewport" content="width=device-width initial-scale=1.0 maximum-scale=1.0 user-scalable=yes" />
<link type="text/css" rel="stylesheet" href="{OSSURL}public/mobile/css/mKtdt.css?v=4.85" />
<link type="text/css" rel="stylesheet" href="{OSSURL}public/mobile/css/jquery-emoji.css?v=4.85" />
<link type="text/css" rel="stylesheet" href="{OSSURL}public/mobile/css/greenStyle.css?v=4.80120" />
{php echo register_jssdk();}
<script type="text/javascript" src="{OSSURL}public/mobile/js/jquery-1.11.3.min.js?v=4.8"></script>
<script src="http://res.wx.qq.com/open/js/jweixin-1.0.0.js"></script>
<script type="text/javascript" src="{OSSURL}public/mobile/js/PromptBoxUtil.js?v=4.80309"></script>
<script type="text/javascript" src="{OSSURL}public/mobile/js/jquery.emoji.js?v=4.8"></script>
</head>
<body>
<div class="all allBg">
<div class="swiper-container" style="display:none">
    <div class="swiper-wrapper">
        <div class="swiper-slide"></div>
    </div>
    <!-- Add Pagination -->
    <div class="swiper-pagination"></div>
</div>

<div id="BlackBg" class="BlackBg"></div>

<div id="titlebar" class="header mainColor">
	<div class="l"><a class="backOff" href="javascript:history.go(-1);"></a></div>
	<div class="m">
		<span style="font-size: 18px">发布作业</span>   
	</div>
		<div class="r">
			<a href="#my-menu"></a>
		</div>
</div>
<div id="titlebar_bg" class="_header"></div>	
	  <div id="fullbg" class="fullbg"></div>
		  	<div class="sendInfo wot pr">
              <a href="javascript:cancel();" class="sendBtn cancelNewBtn f15 db c2" >取消</a>
              <a href="javascript:sendPhoto();" class="sendBtn  f15 db c2" >发布</a>
		    </div>
		      <div class="textBox">
			    <span class="r">
				  <input id="title" type="text" placeholder="作业标题...">
			    </span>
			  </div>
		      <div class="textInfo">
			    <textarea id="content" type="text" name="content" cols rows placeholder="详细内容..."></textarea>
			  </div>
			  <div id="imageBox" class="imageBox">
			  </div>
			<div id="pic" class="pic parent"></div>
			<div class="blackBg" onclick="closeBox();"></div>
			<div class="selectList">
			  <div class="single" id="bjList">
				<ul>
                    {if !empty($teachers['bj_id1'])}<li onclick="isSelect(this);"><span class="le">{$name1}</span><input type=hidden value="{$bjid1}" /></li>{/if}
					{if !empty($teachers['bj_id2'])}<li onclick="isSelect(this);"><span class="le">{$name2}</span><input type=hidden value="{$bjid2}" /></li>{/if}
					{if !empty($teachers['bj_id3'])}<li onclick="isSelect(this);"><span class="le">{$name3}</span><input type=hidden value="{$bjid3}" /></li>{/if}
	            </ul> 
			  </div>
		    </div>
		    <div class="sendParam sendParam_wot pr" onclick="showSelectBox('bjList')" >
			  <span class="locationCon address f15" closestatus="0">
			      <i class="iconloc bj_icon_background-position float_left"></i>选择班级
			  </span>
			  <span class="sendSelectParamOperBtn pa address f15 c9" closestatus="0" id="bjListShow"></span>
		      <input id="bjListValue" name="bjListValue" type="hidden">
			  <span class="sendParamOperBtn pa address f15 c9" closestatus="0">
			       <i class="iconloc fx_icon_background-position float_left"></i>
			  </span>
	        </div>
			<div class="blackBg1" onclick="closeBox1();"></div>
			<div class="selectList1">
			  <div class="single1" id="kmList">
				<ul>
                    {if !empty($teachers['km_id1'])}<li onclick="isSelect1(this);"><span class="le1">{$kmname1}</span><input type=hidden value="{$teachers['km_id1']}" /></li>{/if}
					{if !empty($teachers['km_id2'])}<li onclick="isSelect1(this);"><span class="le1">{$kmname2}</span><input type=hidden value="{$teachers['km_id2']}" /></li>{/if}
	            </ul> 
			  </div>
		    </div>
		    <div class="sendParam1 sendParam_wot1 pr" onclick="showSelectBox1('kmList')" >
			  <span class="locationCon address f15" closestatus="0">
			      <i class="iconloc1 xm_icon_background-position float_left1"></i>选择科目
			  </span>
			  <span class="sendSelectParamOperBtn1 pa address f15 c9" closestatus="0" id="kmListShow"></span>
		      <input id="kmListValue" name="kmListValue" type="hidden">
			  <span class="sendParamOperBtn1 pa address f15 c9" closestatus="0">
			       <i class="iconloc1 fx_icon_background-position float_left1"></i>
			  </span>
	        </div>			
</div>
<!-- yinru -->
<script type="text/javascript">
/**
 * 课堂动态新增页面
 */
var PB = new PromptBox();

function cancel(){
	history.go(-1);
}
$(function(){
	createImageBox();
 });

function showSelectBox(obj){
	if($("#"+obj).find("ul").children().length > 0){
		$(".selectList").css("display","block");
		$(".blackBg").css("display","block");
		$("#"+obj).css("display","block");
		var height = 0;
		if($("#"+obj).attr("class") == "double"){
			$("#"+obj).css("height",$(".selectList").height());
			$("#"+obj).find("ul").css("height",$(".selectList").height()-50);
			var objList;
			if($("#"+obj+"Value").val() != ""){
				objList = $("#"+obj+"Value").val().split(",");
				var liList = $("#"+obj).find("li");
				for (var j = 0; j < liList.length; j++) {
					for (var i = 0; i < objList.length; i++) {
						if(objList[i] == liList.eq(j).find("input[type=hidden]").val()){
							liList.eq(j).find("img").attr("alt","checked");
							liList.eq(j).find("img").attr("src",ctx+"/static/styles/bjq/img/checked.png");
							liList.eq(j).find("input[type=hidden]").attr("name","checked");
							liList.eq(j).find("span[class=le]").attr("name","checkedName");
							break;
						}else{
							liList.eq(j).find("img").attr("alt","check");
							liList.eq(j).find("img").attr("src",ctx+"/static/styles/bjq/img/check.png");
							liList.eq(j).find("input[type=hidden]").attr("name","check");
							liList.eq(j).find("span[class=le]").attr("name","checkName");
						}
					}
				}
			}else{
				$("#"+obj).find("img").attr("alt","check");
				$("#"+obj).find("img").attr("src",ctx+"/static/styles/bjq/img/check.png");
				$("#"+obj).find("input[type=hidden]").attr("name","check");
				$("#"+obj).find("span[class=le]").attr("name","checkName");
			}
		}else{
			$("#"+obj).css("height",$(".selectList").height());
			$("#"+obj).find("ul").css("height",$(".selectList").height());
		}
		$(".selectList").css("margin-top",-$("#"+obj).parent().height()/2);	
	}
}

function closeBox(){
	$(".selectList").css("display","none");
	$(".blackBg").css("display","none");
	$(".single").css("display","none");
	$(".double").css("display","none");
	$(".double").css("height","auto");
	$(".double").find("ul").css("height","auto");
}

function isSelect(obj){
	$(obj).parent().children().removeAttr("class");
	$(obj).parent().find("span[class=le]").attr("name","selectName");
	$(obj).parent().find("input[type=hidden]").attr("name","select");
	$(obj).attr("class","selected");
	$(obj).find("span[class=le]").attr("name","selectedName");
	$(obj).find("input[type=hidden]").attr("name","selected");
	saveSelected(obj);
	closeBox();
}

function saveSelected(obj){
	var boxName = $(obj).parent().parent().attr("id");
	var selectedName = $(obj).find("span[class=le][name=selectedName]");
	var selectedValue = $(obj).find("input[type=hidden][name=selected]");
	$("#"+boxName+"Show").html(selectedName.html());
	$("#"+boxName+"Value").val(selectedValue.val());
}

function showSelectBox1(obj){
	if($("#"+obj).find("ul").children().length > 0){
		$(".selectList1").css("display","block");
		$(".blackBg1").css("display","block");
		$("#"+obj).css("display","block");
		var height = 0;
		if($("#"+obj).attr("class") == "double"){
			$("#"+obj).css("height",$(".selectList1").height());
			$("#"+obj).find("ul").css("height",$(".selectList1").height()-50);
			var objList;
			if($("#"+obj+"Value").val() != ""){
				objList = $("#"+obj+"Value").val().split(",");
				var liList = $("#"+obj).find("li");
				for (var j = 0; j < liList.length; j++) {
					for (var i = 0; i < objList.length; i++) {
						if(objList[i] == liList.eq(j).find("input[type=hidden]").val()){
							liList.eq(j).find("img").attr("alt","checked");
							liList.eq(j).find("img").attr("src",ctx+"/static/styles/bjq/img/checked.png");
							liList.eq(j).find("input[type=hidden]").attr("name","checked");
							liList.eq(j).find("span[class=le1]").attr("name","checkedName");
							break;
						}else{
							liList.eq(j).find("img").attr("alt","check");
							liList.eq(j).find("img").attr("src",ctx+"/static/styles/bjq/img/check.png");
							liList.eq(j).find("input[type=hidden]").attr("name","check");
							liList.eq(j).find("span[class=le1]").attr("name","checkName");
						}
					}
				}
			}else{
				$("#"+obj).find("img").attr("alt","check");
				$("#"+obj).find("img").attr("src",ctx+"/static/styles/bjq/img/check.png");
				$("#"+obj).find("input[type=hidden]").attr("name","check");
				$("#"+obj).find("span[class=le1]").attr("name","checkName");
			}
		}else{
			$("#"+obj).css("height",$(".selectList1").height());
			$("#"+obj).find("ul").css("height",$(".selectList1").height());
		}
		$(".selectList1").css("margin-top",-$("#"+obj).parent().height()/2);	
	}
}

function closeBox1(){
	$(".selectList1").css("display","none");
	$(".blackBg1").css("display","none");
	$(".single1").css("display","none");
	$(".double1").css("display","none");
	$(".double1").css("height","auto");
	$(".double1").find("ul").css("height","auto");
}

function isSelect1(obj){
	$(obj).parent().children().removeAttr("class");
	$(obj).parent().find("span[class=le1]").attr("name","selectName");
	$(obj).parent().find("input[type=hidden]").attr("name","select");
	$(obj).attr("class","selected1");
	$(obj).find("span[class=le1]").attr("name","selectedName1");
	$(obj).find("input[type=hidden]").attr("name","selected1");
	saveSelected1(obj);
	closeBox1();
}

function saveSelected1(obj){
	var boxName = $(obj).parent().parent().attr("id");
	var selectedName1 = $(obj).find("span[class=le1][name=selectedName1]");
	var selectedValue1 = $(obj).find("input[type=hidden][name=selected1]");
	$("#"+boxName+"Show").html(selectedName1.html());
	$("#"+boxName+"Value").val(selectedValue1.val());
}

function sendPhoto(){
	var content = $("#content").val();
	var title = $("#title").val();
//	var photoUrlArray = new Array();
//	$(".boxImages").each(function() {
//		if($(this).hasClass("baseUploadImg")){
//			photoUrlArray.push($(this).attr("src"));
//		}
//	});
	if(title=='' || title.length>30){
		PB.prompt("标题必填，且字数小于30字！");
		return false;
	}
	if(content==''){
		PB.prompt("文字内容不能为空");
		return false;
	}
	var bjid =  $("#bjListValue").val(); 
	if(bjid == undefined || bjid == null || bjid == "" ){
		PB.prompt("请选择班级！");
		return false;
	}
	var kmid =  $("#kmListValue").val(); 
	if(kmid == undefined || kmid == null || kmid == "" ){
		PB.prompt("请选择科目！");
		return false;
	}	
	
	var photoUrls = images.serverId.join(',');

	if (confirm("确定发布?")) {
		PB.prompt("信息发布中，请勿关闭本页面~","forever");
		var submitData = {
			weid:"{$weid}",
			bj_id : bjid,   //班级
			km_id : kmid,   //班级
			openid : "{$openid}",
			schoolid : "{$schoolid}",
			title : title,
			content : content,
			tid:"{$it['tid']}",
			tname:"{$isbzr['tname']}",//当前教师名字
			photoUrls : photoUrls,
		};
	    $.post("{php echo $this->createMobileUrl('dongtaiajax',array('op'=>'zfabu'))}",submitData,function(data){

            if(data.result){
                PB.prompt(data.msg);
				location.href = "{php echo $this->createMobileUrl('zuoyelist', array('schoolid' => $schoolid), true)}";
            }else{
				PB.prompt(data.msg);
            }
		},'json'); 		
	}
}
</script>
</body>
</html>